// 引入axios
import axios from 'axios';
import { AxiosInstance,InternalAxiosRequestConfig  } from 'axios';
import store from '@/store';

let baseUrl="http://localhost:80/";

const yrtAxiosInstance:AxiosInstance = axios.create({
    baseURL: baseUrl,
    timeout: 60000
});

// 添加请求拦截器
yrtAxiosInstance.interceptors.request.use(function (config: InternalAxiosRequestConfig) {
    console.log("store=" + store.getters.GET_TOKEN);
    
    // 确保 headers 不为 undefined
    config.headers = config.headers || {};
    
    // 设置 token
    config.headers['token'] = store.getters.GET_TOKEN;
    
    return config;
});